//
//  KDTableViewCell.m
//  M800Project
//
//  Created by 姚宗超 on 14/11/6.
//  Copyright (c) 2014年 姚宗超. All rights reserved.
//

#import "KDTableViewCell.h"

@implementation KDTableViewCell

+ (CGFloat)rowHeightForObject:(id)object
{
    return 50.0f;
}

+ (CGFloat)estimateRowsHeight
{
    return 50.0f;
}

+ (BOOL)shouldUseAutoLayout
{
    return NO;
}

- (void)awakeFromNib {
    // Initialization code
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)dealloc
{
    [self finishObserveObjectProperty];
}

- (void)setObject:(id)object {
    if (object != _object) {
        if (_object != nil) {
            [self finishObserveObjectProperty];
        }
        
        _object = object;
        if (_object != nil)
            [self startObserveObjectProperty];
    }
}

#pragma mark Object Property Observer

- (void)startObserveObjectProperty {
    
}

- (void)finishObserveObjectProperty {
    
}

- (void)addObservedProperty:(NSString *)property {
    [_object addObserver:self forKeyPath:property
                 options:NSKeyValueObservingOptionNew
                 context:nil];
}

- (void)removeObservedProperty:(NSString *)property {
    [_object removeObserver:self forKeyPath:property];
}

- (void)objectPropertyChanged:(NSString *)property {
    
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    if (object != _object) {
        [object removeObserver:self forKeyPath:keyPath];
    }
    else {
        [self objectPropertyChanged:keyPath];
    }
}

@end
